// 兼容 cjs, rollup默认情况下只会处理es module
const commonjs = require("@rollup/plugin-commonjs");
const nodeResolve = require("@rollup/plugin-node-resolve");

// 使用代码转换和压缩
const { babel } = require("@rollup/plugin-babel");
const terser = require("@rollup/plugin-terser");

module.exports = {
    external: ["lodash"],
    input: "index.js",
    output: [
        {
            format: "cjs",
            file: "dist/bundle.cjs.js"
        },
        {
            format: "es",
            file: "dist/bundle.es.js"
        },
        {
            format: "iife",
            name: "ikunUtils",
            file: "dist/bundle.browser.js",
            globals: {
                lodash: "_"
            }
        },
        {
            format: "umd",
            name: "ikunUtils",
            file: "dist/bundle.umd.js",
            globals: {
                lodash: "_"
            }
        }
    ],
    plugins: [
        commonjs(),
        nodeResolve(),
        babel({
            babelHelpers: "bundled",
            exclude: /node_modules/
        }),
        terser()
    ]
};
